package statcomponent.demo;

import lombok.extern.slf4j.Slf4j;
import statcomponent.StatContext;
import statcomponent.StatManager;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;

/**
 * 测试案例
 *
 * @author chen
 * @date 2023年07月29日 10:06
 */
@Slf4j
public class DemoMain {
    public static void main(String[] args) {
        List<Student> students = new ArrayList<>();
        Student stu1 = new Student(11,98D,95D,87D);
        Student stu2 = new Student(12,97D,56D,78D);
        //构建list
        students.add(stu1);
        students.add(stu2);
        //创建全局对象
        StatResult statResult = new StatResult();
        //构建统计上下文
        StatContext<StatResult> context = StatManager.buildStatStudentContext(statResult);
        //进行统计
        StatManager.execute(students,context);
        //输出结果
        log.info("统计结果：" + statResult);




        Double chineseSum = 0d;
        //班级积分
        Double classScore = 0d;
        //定义变量
//        .....
        for(Student student : students){
            //统计语文成绩
            chineseSum += student.getChinese();
            //统计班级成绩
            classScore += student.getClassScore();
            //统计.....
        }
    }


}
